"""
创建字典
"""
dict1 = {'name': 'Tom', 'age': 20, 'sex': "男"}
print(dict1)
print(type(dict1))

dict2 = {}
print(type(dict2))

dict3 = dict()
print(type(dict3))

"""
字典修改
del()
clear()
"""
dict1['name'] = "Answer"
print(dict1['name'])
del (dict1['name'])
print(dict1)
dict1.clear()
print(dict1)

"""
修改与新增
"""
dict4 = {'name': 'Tom', 'age': 20, 'sex': "男"}
dict4['id'] = 110
dict4['sex'] = "女"
print(dict4)

"""
查找
get()
keys()
values()
items()
"""
print(dict4['name'])
print(dict4.get('name', '不存在此参数'))
print(dict4.get('high', '不存在此参数'))

for key in dict4.keys():
    print(key)
for value in dict4.values():
    print(value)
for item in dict4.items():
    print(item)

for key, value in dict4.items():
    print(f"{key}={value}")
